let common = require('./base/common');
let StringHashTable = require('./dataStruct/stringHashTable').StringHashTable;

/**
 * 字符串Hash表测试
 * 
 * @param {*} matchs 输入集合
 * @param {*} tests 测试集合
 * @returns 
 */
let stringHashTableOpt = function(matchs, tests) {
    let hashTable = new StringHashTable(parseInt(matchs.length / 0.25));
    
    for(let m of matchs) {
        hashTable.add(m);
    }

    let count = 0;
    for(let t of tests) {
        count += hashTable.has(t)? 1: 0;
    }

    return count;
} 

common.testing([
    [["helloworld", "sit", "meeting", "hello", "world", "hell0"], ["helloworld", "sort", "hello"]],
    [["", "helloworld"], [""]]
])(x => stringHashTableOpt(x[0], x[1]));